<template>
    <h2>会员信息录入</h2>
    <table>
        <tr>
            <th>姓名</th>
            <th>
                <input type="text" v-model="data.uname">
            </th>
        </tr>
        <tr>
            <th>性别</th>
            <th>
                <input type="radio" value="true" name="sex" v-model="data.sex">男
                <input type="radio" value="false" name="sex" v-model="data.sex" checked>女
            </th>
        </tr>
        <tr>
            <th>手机号</th>
            <th>
                <input type="text" v-model="data.phone">
            </th>
        </tr>
        <tr>
            <th>会员等级</th>
            <th>
                <select v-model="data.huiyuan">
                    <option value="0">请选择</option>
                    <option value="1">VIP</option>
                    <option value="2">超级VIP</option>
                </select>
            </th>
        </tr>
        <tr>
            <th>消费金额</th>
            <th>
                <input type="text" v-model="data.jine">
            </th>
        </tr>
        <tr>
            <th>消费次数</th>
            <th>
                <input type="text" v-model="data.chishu">
            </th>
        </tr>
        <tr>
            <th>可用积分</th>
            <th>
                <input type="text" v-model="data.jifen">
            </th>
        </tr>
        <tr>
            <th>可用余额</th>
            <th>
                <input type="text" v-model="data.yue">
            </th>
        </tr>
        <tr>
            <th>启用状态</th>
            <th>
                <input type="radio" value="1" name="zhuangtai" v-model="data.zhuangtai">启用
                <input type="radio" value="2" name="zhuangtai" v-model="data.zhuangtai">禁用
            </th>
        </tr>
        <tr>
            <th>日期</th>
            <th>
                <input type="date" v-model="data.time">
            </th>
        </tr>
        <tr>
            <th></th>
            <th>
                <input type="button" value="注册" @click="audd">
            </th>
        </tr>
    </table>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router=useRouter()
const data=ref({
"uid": 0,
  "uname": "",
  "sex": true,
  "phone": "",
  "huiyuan": 0,
  "jine": "",
  "chishu": "",
  "jifen": "",
  "yue": "",
  "zhuangtai": 0,
  "time": ""
})

const audd=()=>{
    if(data.value.uname=="")
     {
        alert('姓名不为空');
        return;
     }
     if(data.value.phone=="")
     {
        alert('手机号不为空');
        return;
     }
     if(data.value.jine=="")
     {
        alert('消费金额不为空');
        return;
     }
     if(data.value.chishu=="")
     {
        alert('消费次数不为空');
        return;
     }
     if(data.value.jifen=="")
     {
        alert('可用积分不为空');
        return;
     }

     if(data.value.yue=="")
     {
        alert('可用余额不为空');
        return;
     }
    axios.post("https://localhost:7182/api/VS/Add",data.value).then(res=>{
     

        if(res.data>0)
    {
        alert('注册成功');
        router.push({path:"/show"})
    }
    else
    {
        alert('注册失败');
        return;
    }
    })
}

</script>

<style scoped>

</style>